using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter10
{
	/// <summary>
	/// Example04: Four Rotating Objects
	/// Four tiny spheres are fastened to the ends of two rods 
	/// of negligible mass lying in the xy plane (Figure 10.8a). 
	/// We shall assume that the radii of the spheres are small 
	/// compared with the dimensions of the rods.
	/// (A) If the system rotates about the axis (Figure 10.8a) 
	/// with an angular speed, find the moment of inertia and 
	/// the rotational kinetic energy about this axis.
	/// I_y = 2 M a^2
	/// K = M a^2 \omega^2
	/// (B) Suppose the system rotates in the xy plane about 
	/// an axis (the z axis) through O (Figure 10.8b).
	/// Calculate the moment of inertia and rotational kinetic 
	/// energy about this axis.
	/// I_z = 2 M a^2 + 2 m b^2
	/// K = (M a^2 + m b^2)\omega^2
	/// </summary>
	public class Example04
	{
		public Example04()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.Mass[] M = new L.Mass[4];
			M[0] = new L.Mass();
			M[0].kg = 10.0;
			M[1] = new L.Mass();
			M[1].kg = 3.0;
			M[2] = new L.Mass();
			M[2].kg = 10.0;
			M[3] = new L.Mass();
			M[3].kg = 3.0;
			L.Position[] a = new L.Position[4];
			a[0] = new L.Position();
			a[0].X = 2.0;
			a[1] = new L.Position();
			a[1].Y = 7.0;
			a[2] = new L.Position();
			a[2].X = -2.0;
			a[3] = new L.Position();
			a[3].Y = -7.0;
			L.MomentOfInertia I = new L.MomentOfInertia(M,a);
			//(A)
			result+=Convert.ToString(I.YY)+"\r\n";
			L.AngularVelocity omega = new L.AngularVelocity();
			omega.Y = 3.0;
			L.KineticEnergy K1 = new L.KineticEnergy(I,omega);
			result+=Convert.ToString(K1.J)+"\r\n";
			//(B)
			result+=Convert.ToString(I.ZZ)+"\r\n";
			L.AngularVelocity omega2 = new L.AngularVelocity();
			omega2.Z = 6.0;
			L.KineticEnergy K2 = new L.KineticEnergy(I,omega2);
			result+=Convert.ToString(K2.J)+"\r\n";
		}
	}
}
